package top.sehnsucht.service.impl;

import top.sehnsucht.dao.ExcelDao;
import top.sehnsucht.service.ExcelService;
import top.sehnsucht.utils.ExcelUtil;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Map;

/**
 * @Description:
 * @Author: Cai
 * @CreateTime: 2021/11/19
 */

public class ExcelServiceImpl implements ExcelService {
    private ExcelDao dao;

    public ExcelServiceImpl(ExcelDao dao) {
        this.dao = dao;
    }

    @Override
    public void createExcel(String name, ArrayList<String> list) {
        try {
            dao.createExcel(name, list);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void addExcel(String name, ArrayList<String> list, ArrayList<String> data) {
        try {
            dao.addExcel(name, list, data);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public ArrayList<Map<String, String>> showTable() {
        try {
            return dao.showTable();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public void DataToExcel(String name,String path) {
        try {
            ExcelUtil.createExcelFile(name,path);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
